package ar.com.mooral.activities;



import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import ar.com.mooral.crohn.Synchronizer;
import ar.com.mooral.crohn.application.CrohnContext;
import ar.com.mooral.data.Result;


public class CodigoMedico extends CrohnActivity{
	
	private EditText txtCodigoMedico; 
	
	/** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.codigo_medico);

        final Context context = this.getApplicationContext();
        
       	txtCodigoMedico = (EditText) findViewById(R.id.txtCodigoMedicoCodigo);        
        
        
        // Ingresar
		Button btnCodigoMedicoIngresar = (Button) findViewById(R.id.btnCodigoMedicoIngresar);
		btnCodigoMedicoIngresar.setOnClickListener (new View.OnClickListener() {
		    public void onClick(View view) {


		    	Synchronizer sync = new Synchronizer(context);
		    	String code = txtCodigoMedico.getText().toString();
		    	Result r = sync.validateCode(code);
		    	
		    	if (r.hasError()) {
		    		showMessage(r);
		    	} else {
					//CrohnContext.setMedicalCode(code);
					Intent intent = new Intent();
					//intent.setComponent(new ComponentName(IngresoUsuarioPassword.class.getPackage().getName(), IngresoUsuarioPassword.class.getName()));
					intent.setComponent(new ComponentName(Informacion.class.getPackage().getName(), Informacion.class.getName()));
					startActivity(intent);
		    	}

		    }
		});	
		
		// Cancelar
		Button btnCodigoMedicoCancelar = (Button) findViewById(R.id.btnCodigoMedicoCancelar);
		btnCodigoMedicoCancelar.setOnClickListener (new View.OnClickListener() {
		    public void onClick(View view) {
		    	finish();
		    	}	    	
		});

        
     
    }
    
}